function plotUSWMSync(US,WM,SYNC_US,SYNC_WM,xcorr_result,freq_aq,type,filename,dif,max_xcorr_index,max_correlation_value_xcorr)

    close all
    scrsz = get(0,'ScreenSize'); %answers 1 1 1920 1080 in my screen
    figure('Position',[0 50 1000 900]) %[left bottom width height] - places figure in the whole window
    set(gcf, 'color', 'w'); %White background

    n_frm_US = length(US);  
    %BEFORE CORRELATION PLOT
    subplot(2,2,1);           
    t_sinc = 0 :n_frm_US-1;
    t_sinc = t_sinc/freq_aq;    
    plot(t_sinc,WM,'-r',t_sinc,US,'-b');
    xlabel('time (s)');
    if(strcmp(type,'VF'))||(strcmp(type,'VF2'))
        ylabel('\alpha(%)');
    elseif(strcmp(type,'WL'))
        ylabel('Distance (m)');
    end
    %limit_x = max(t_sinc);
    hleg1 = legend('wiremesh','ultrasound');
    set(hleg1,'Location','NorthWest')
    set(hleg1,'Interpreter','none')
    set(gca,'XLim',[0 2]);
    title('Original time-series');   

    % CORRELATION PLOT
    subplot(2,2,2);        
    plot(xcorr_result);  
    title(sprintf('X-Correlation - Delay = %G (frames)',dif));        
    line([max_xcorr_index max_xcorr_index],[0 max_correlation_value_xcorr],'Color','r','LineStyle',':','LineWidth',2);
    line([length(US) length(US)],[0 max_correlation_value_xcorr],'LineStyle','-','Color',[0 0 0]); %Draw lines in the plot [x_start x_end y_start y_end]
    set(gca,'XLim',[(length(US)-2*abs(dif)-10) (length(US)+2*abs(dif)+10)]);
    n_frm_US = length(SYNC_US);  
    % ZOOM PLOT
    subplot(2,2,3);
    t_sinc = 0 :n_frm_US - 1;
    t_sinc = t_sinc/freq_aq;    
    plot(t_sinc,SYNC_WM,'-r',t_sinc,SYNC_US,'-b');
    xlabel('time (s)');
    if(strcmp(type,'VF'))||(strcmp(type,'VF2'))
        ylabel('\alpha(%)');
    elseif(strcmp(type,'WL'))
        ylabel('Distance (m)');
    end
    limit_x = max(t_sinc);
    set(gca,'XLim',[0 limit_x/5]);
    hleg1 = legend('wiremesh','ultrasound');
    set(hleg1,'Location','NorthWest')
    set(hleg1,'Interpreter','none')
    title('WM selection - zoom');        

    % ALL DATA PLOT
    subplot(2,2,4);
    t_sinc = 0 :n_frm_US - 1;
    t_sinc = t_sinc/freq_aq;    
    plot(t_sinc,SYNC_WM,'-r',t_sinc,SYNC_US,'-b');
    xlabel('time (s)');
    if(strcmp(type,'VF'))||(strcmp(type,'VF2'))
        ylabel('\alpha(%)');
    elseif(strcmp(type,'WL'))
        ylabel('Distance (m)');
    end
    limit_x = max(t_sinc);
    set(gca,'XLim',[0 limit_x]);
    hleg1 = legend('wiremesh','ultrasound');
    set(hleg1,'Location','NorthWest')
    set(hleg1,'Interpreter','none')
    title('WM selection - whole data');      
    if (exist('.\Results_sync','dir') == 0)            %Creates Result directory if it does not exist yeat
      mkdir('Results_sync');  
    end  
    
    if(strcmp(type,'VF'))
        str='void';
    elseif(strcmp(type,'VF2'))    
        str='midle_electrode_void';
    elseif(strcmp(type,'WL'))
        str='waterlevel';
    end

    name_figure_fig = ['.\Results_sync\Figure_US_WM' filename '_' str '.fig'];
    name_figure_emf = ['.\Results_sync\Figure_US_WM' filename '_' str '.tif'];
    saveas(gcf,name_figure_fig); 
    saveas(gcf,name_figure_emf);        


end